package com.xxxx.server.controller;


import com.xxxx.server.pojo.RespBean;
import com.xxxx.server.pojo.Salary;
import com.xxxx.server.service.ISalaryService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhoubin
 * @since 2020-10-15
 */
@Api("工资")
@RestController
@RequestMapping("/salary")
public class SalaryController {

    @Autowired
    private ISalaryService iSalaryService;

    /**
     * 获取全部工资账套
     * @return
     */
    @GetMapping("/sob")
    @ResponseBody
    public List<Salary> list(){
        return iSalaryService.list();
    }

    /**
     * 添加工资账套
     * @param salary
     * @return
     */
    @PostMapping("/sob")
    @ResponseBody
    public RespBean save(@RequestBody Salary salary){
        return iSalaryService.saveSalary(salary);
    }

    /**
     * 更新工资账套
     * @param salary
     * @return
     */
    @PutMapping("/sob")
    @ResponseBody
    public RespBean edit(@RequestBody Salary salary){
        return iSalaryService.editSalary(salary);
    }

    /**
     * 删除工资账套
     * @param id
     * @return
     */
    @DeleteMapping("/sob/{id}")
    @ResponseBody
    public RespBean delete(@PathVariable Integer id){
        return iSalaryService.delete(id);
    }

    /**
     * 查询所有员工部分信息及工资账套
     * @return
     */
    @GetMapping("/sobcfg")
    @ResponseBody
    public Map<String,Object> sobCfgList(Integer currentPage,Integer size){

        return iSalaryService.empSalList(currentPage,size);
    }

    /**
     * 更新员工部工资账套
     * @return
     */
    @PutMapping("/sobcfg")
    @ResponseBody
    public RespBean updateEmpSal(Integer eid,Integer sid){
        return iSalaryService.updateEmpSal(eid,sid);
    }

    /**
     * 查询所有员工部分信息及工资账套
     * @return
     */
    @GetMapping("/sobcfg/salaries")
    @ResponseBody
    public List<Salary> sobCfgList(){

        return iSalaryService.list();
    }

}
